import { useAppSelector } from '@/hooks/store';

interface PermissionProps {
  permission: string;
  children: React.ReactNode;
}

const Permission: React.FC<PermissionProps> = ({ permission, children }) => {
  const permissions = useAppSelector((state) => state.user.permissions);

  if (!permission || permissions.includes(permission)) {
    return <>{children}</>;
  }

  return null;
};

export default Permission;
